Skip to content

Latest commit

 

History

History
42 lines (25 loc) · 1.42 KB

File metadata and controls

42 lines (25 loc) · 1.42 KB
uid
NetCode.DependencyInjection.Index

Depedency Injection in 2sxc and EAV

Dependency Injection is a way to structure applications and to get Services or Helpers in your code.

👉 We suggest you read the introduction to Dependency Injection

How Can I Use Dependency Injection in Razor?

Previously this was reserved for internal use. Starting in 2sxc v11.11 all Razor classes have a command called GetService. This is how your code would get a service:

@inherits Custom.Hybrid.Razor14
@Kit.Page.AddOpenGraph("video", "https://2sxc.org/videos/intro.mp4");

👉 Read more about GetService in the docs or in the GetService API.

How Can I Use Dependency Injection in WebAPIs?

Just like with with Razor, 2sxc 11.11 added the same GetService to all WebAPIs.

How Can I Use Dependency Injection in Dnn Modules and Skins

👉

How Can I Use Dependency Injection in Oqtane

👉

Services My Code May Need

You can get just about anything from 2sxc. The most common services you'll request as of 2sxc 12 are in the ToSic.Sxc.Services namespace.

[!include"history"]